package com.wcgksoft.controller.mainten;


import com.google.gson.JsonObject;
import com.wcgksoft.common.util.MsgInfo;
import com.wcgksoft.entity.ConstructionTeam.ConstructionTeam;
import com.wcgksoft.entity.mainten.Mainten;
import com.wcgksoft.entity.system.EnterpriseProject;
import com.wcgksoft.entity.system.SysUser;
import com.wcgksoft.service.ConstructionTeam.ConstructionTeamService;
import com.wcgksoft.service.mainten.MaintenService;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * 养护统计
 *
 * @author Administrator
 */
@Controller
@RequestMapping("maintenstatistics")
public class MaintenStatisticsController {

    @Autowired
    private MaintenService maintenService;
    @Autowired
    private ConstructionTeamService constructionTeamService;
    /**
     * 头部豆腐块 +全部队伍 4种分类 饼图
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping(value="top")
    public MsgInfo statistics(@RequestParam(value = "teamid", required = false) String teamid){
        MsgInfo msgInfo = new MsgInfo();
        DetachedCriteria criteria = DetachedCriteria.forClass(Mainten.class);
        SysUser sysUser = (SysUser) SecurityUtils.getSubject().getSession().getAttribute("om_user");
        EnterpriseProject enterpriseProject = (EnterpriseProject) SecurityUtils.getSubject().getSession().getAttribute("area");
        criteria.add(Restrictions.eq("departid", sysUser.getProId()+""));
        criteria.add(Restrictions.eq("areaid", enterpriseProject.getId()+""));

        JsonObject test=new JsonObject();
        String day = "";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        java.util.Date dd  = Calendar.getInstance().getTime();
        day = sdf.format(dd);
        //当天
        criteria.add(Restrictions.like("maintenanceDate",day, MatchMode.ANYWHERE));
        if(StringUtils.isNotEmpty(teamid)) {
            criteria.add(Restrictions.eq("maintenanceTroops", teamid));
        }
        List<Mainten> listd = maintenService.findByConditions(criteria);
        if(listd.size()>0){
            test.addProperty("day", listd.size());
        }else{
            test.addProperty("day", 0);
        }

        //当月全部
        String month = "";
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM");
        java.util.Date dd1  = Calendar.getInstance().getTime();
        month = sdf1.format(dd1);
        DetachedCriteria criteriam = DetachedCriteria.forClass(Mainten.class);
        criteriam.add(Restrictions.eq("departid", sysUser.getProId()+""));
        criteriam.add(Restrictions.eq("areaid", enterpriseProject.getId()+""));
        criteriam.add(Restrictions.like("maintenanceDate",month, MatchMode.ANYWHERE));
        if(StringUtils.isNotEmpty(teamid)) {
            criteriam.add(Restrictions.eq("maintenanceTroops", teamid));
        }

        List<Mainten> listm = maintenService.findByConditions(criteriam);
        if(listm.size()>0){
            test.addProperty("month", listm.size());
        }else{
            test.addProperty("month", 0);
        }

        //当月绿地
        DetachedCriteria criterial = DetachedCriteria.forClass(Mainten.class);
        criterial.add(Restrictions.eq("departid", sysUser.getProId()+""));
        criterial.add(Restrictions.eq("areaid", enterpriseProject.getId()+""));
        criterial.add(Restrictions.eq("type", 1));
        criterial.add(Restrictions.like("maintenanceDate",month, MatchMode.ANYWHERE));
        if(StringUtils.isNotEmpty(teamid)) {
            criterial.add(Restrictions.eq("maintenanceTroops", teamid));
        }
        List<Mainten> listl = maintenService.findByConditions(criterial);
        if(listl.size()>0){
            test.addProperty("lv", listl.size());
        }else{
            test.addProperty("lv", 0);
        }

        //当月卫生
        DetachedCriteria criteriav = DetachedCriteria.forClass(Mainten.class);
        criteriav.add(Restrictions.eq("departid", sysUser.getProId()+""));
        criteriav.add(Restrictions.eq("areaid", enterpriseProject.getId()+""));
        criteriav.add(Restrictions.eq("type", 2));
        criteriav.add(Restrictions.like("maintenanceDate",month, MatchMode.ANYWHERE));
        if(StringUtils.isNotEmpty(teamid)) {
            criteriav.add(Restrictions.eq("maintenanceTroops", teamid));
        }
        List<Mainten> listv = maintenService.findByConditions(criteriav);
        if(listv.size()>0){
            test.addProperty("ws", listv.size());
        }else{
            test.addProperty("ws", 0);
        }

        //当月设施
        DetachedCriteria criterias = DetachedCriteria.forClass(Mainten.class);
        criterias.add(Restrictions.eq("departid", sysUser.getProId()+""));
        criterias.add(Restrictions.eq("areaid", enterpriseProject.getId()+""));
        criterias.add(Restrictions.eq("type", 3));
        criterias.add(Restrictions.like("maintenanceDate",month, MatchMode.ANYWHERE));
        if(StringUtils.isNotEmpty(teamid)) {
            criterias.add(Restrictions.eq("maintenanceTroops", teamid));
        }
        List<Mainten> lists = maintenService.findByConditions(criterias);
        if(lists.size()>0){
            test.addProperty("ss", lists.size());
        }else{
            test.addProperty("ss", 0);
        }
        //当月植保
        DetachedCriteria criteriaz = DetachedCriteria.forClass(Mainten.class);
        criteriaz.add(Restrictions.eq("departid", sysUser.getProId()+""));
        criteriaz.add(Restrictions.eq("areaid", enterpriseProject.getId()+""));
        criteriaz.add(Restrictions.eq("type", 4));
        criteriaz.add(Restrictions.like("maintenanceDate",month, MatchMode.ANYWHERE));
        if(StringUtils.isNotEmpty(teamid)) {
            criteriaz.add(Restrictions.eq("maintenanceTroops", teamid));
        }
        List<Mainten> listz = maintenService.findByConditions(criteriaz);
        if(listz.size()>0){
            test.addProperty("zb", listz.size());
        }else{
            test.addProperty("zb", 0);
        }

        //当年
        String year = "";
        SimpleDateFormat sdfy = new SimpleDateFormat("yyyy");
        java.util.Date dd2 = Calendar.getInstance().getTime();
        year = sdfy.format(dd2);
        DetachedCriteria criteriay = DetachedCriteria.forClass(Mainten.class);
        criteriay.add(Restrictions.eq("departid", sysUser.getProId()+""));
        criteriay.add(Restrictions.eq("areaid", enterpriseProject.getId()+""));
        criteriay.add(Restrictions.like("maintenanceDate",year, MatchMode.ANYWHERE));
        if(StringUtils.isNotEmpty(teamid)) {
            criteriay.add(Restrictions.eq("maintenanceTroops", teamid));
        }
        List<Mainten> listy = maintenService.findByConditions(criteriay);
        if(listy.size()>0){
            test.addProperty("year", listy.size());
        }else{
            test.addProperty("year", 0);
        }

        msgInfo.setData(test.toString());
        return msgInfo;
    }

    /**
     * 全部队伍默认4种绿地内容
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping(value="lvdi")
    public MsgInfo lvdi(@RequestParam(value = "teamid", required = false) String teamid){
        MsgInfo msgInfo = new MsgInfo();
        SysUser sysUser = (SysUser) SecurityUtils.getSubject().getSession().getAttribute("om_user");
        EnterpriseProject enterpriseProject = (EnterpriseProject) SecurityUtils.getSubject().getSession().getAttribute("area");
        JsonObject test=new JsonObject();

        String month = "";
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM");
        java.util.Date dd1  = Calendar.getInstance().getTime();
        month = sdf1.format(dd1);
        //当月绿地
        DetachedCriteria criterial = DetachedCriteria.forClass(Mainten.class);
        criterial.add(Restrictions.eq("departid", sysUser.getProId()+""));
        criterial.add(Restrictions.eq("areaid", enterpriseProject.getId()+""));
        criterial.add(Restrictions.eq("type", 1));
        criterial.add(Restrictions.like("maintenanceDate",month, MatchMode.ANYWHERE));
        if(StringUtils.isNotEmpty(teamid)) {
            criterial.add(Restrictions.eq("maintenanceTroops", teamid));
        }
        List<Mainten> list = maintenService.findByConditions(criterial);
        int zg=0; int qd=0; int sf=0;  int fz=0;
        if(list.size()>0){
            for(int i=0;i<list.size();i++){
                if(list.get(i).getMaintenType().getName().equals("中耕除草")){
                    zg++;
                }
                if(list.get(i).getMaintenType().getName().equals("签到打卡")){
                    qd++;
                }
                if(list.get(i).getMaintenType().getName().equals("施肥")){
                    sf++;
                }
                if(list.get(i).getMaintenType().getName().equals("复壮")){
                    fz++;
                }

            }
            test.addProperty("zg", zg);
            test.addProperty("qd", qd);
            test.addProperty("sf", sf);
            test.addProperty("fz", fz);
        }
        msgInfo.setData(test.toString());
        return msgInfo;
    }


    // 获取当月天数
    public List getDayListOfMonth(Date date) {
        List list = new ArrayList();
        Calendar aCalendar = Calendar.getInstance();
        aCalendar.setTime(date);
        int year = aCalendar.get(Calendar.YEAR);// 年份
        int month = aCalendar.get(Calendar.MONTH) + 1;// 月份
        int day = aCalendar.getActualMaximum(Calendar.DATE);
        for (int i = 1; i <= day; i++) {
            String aDate = i + "";
            list.add(aDate);
        }
        return list;
    }
    /**
     * 队伍养护对比年月
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping(value="allny")
    public MsgInfo yr(@RequestParam(value = "teamid", required = false) String teamid){
        MsgInfo msgInfo = new MsgInfo();
        SysUser sysUser = (SysUser) SecurityUtils.getSubject().getSession().getAttribute("om_user");
        EnterpriseProject enterpriseProject = (EnterpriseProject) SecurityUtils.getSubject().getSession().getAttribute("area");
        JsonObject test=new JsonObject();

        //当年
        String year = "";
        SimpleDateFormat sdfy = new SimpleDateFormat("yyyy");
        java.util.Date dd2 = Calendar.getInstance().getTime();
        year = sdfy.format(dd2);

        // 下标当月每天
       int[] mon={1,2,3,4,5,6,7,8,9,10,11,12};

        // 转换成天yyyy-MM-dd格式
        String aDate="";
        String sl="";
        for (int i = 1; i < mon.length + 1; i++) {
            int times;
            if (i < 10) {
                aDate = year + "-0" + i;
            } else {
                aDate = year + "-" + i;
            }
            //当天
            DetachedCriteria criteria = DetachedCriteria.forClass(Mainten.class);
            criteria.add(Restrictions.eq("departid", sysUser.getProId()+""));
            criteria.add(Restrictions.eq("areaid", enterpriseProject.getId()+""));
            criteria.add(Restrictions.like("maintenanceDate",aDate, MatchMode.ANYWHERE));
            if(StringUtils.isNotEmpty(teamid)) {
                criteria.add(Restrictions.eq("maintenanceTroops", teamid));
            }
            List<Mainten> listd = maintenService.findByConditions(criteria);

            if(listd.size()>0){
               times=listd.size();
            }else{
                times=0;
            }
            sl += "," + times;
        }
        sl = sl.replaceFirst(",", "");
        sl = "[" + sl + "]";
        msgInfo.setDatas(sl);
        return msgInfo;
    }


    /**
     * 队伍养护对比月日
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping(value="allyr")
    public MsgInfo ny(@RequestParam(value = "teamid", required = false) String teamid){
        MsgInfo msgInfo = new MsgInfo();
        SysUser sysUser = (SysUser) SecurityUtils.getSubject().getSession().getAttribute("om_user");
        EnterpriseProject enterpriseProject = (EnterpriseProject) SecurityUtils.getSubject().getSession().getAttribute("area");
        JsonObject test=new JsonObject();

        String month = "";
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM");
        java.util.Date dd1  = Calendar.getInstance().getTime();
        month = sdf1.format(dd1);

        // 下标当月每天
        MaintenStatisticsController maintenStatisticsController = new MaintenStatisticsController();
        List list = null;
        try {
            list = maintenStatisticsController.getDayListOfMonth(sdf1.parse(month));
        } catch (ParseException e) {
            e.printStackTrace();
        }

        String xiabiao = "";
        for (int i = 0; i < list.size(); i++) {
            xiabiao += "," + "'" + list.get(i) + "'";
        }
        xiabiao = xiabiao.replaceFirst(",", "");
        xiabiao = "[" + xiabiao + "]";
        // 转换成天yyyy-MM-dd格式
        String aDate = "";
        String sl="";
        for (int i = 1; i < list.size() + 1; i++) {
            int times;
            if (i < 10) {
                aDate = month + "-0" + i;
            } else {
                aDate = month + "-" + i;
            }
            //当天
            DetachedCriteria criteria = DetachedCriteria.forClass(Mainten.class);
            criteria.add(Restrictions.eq("departid", sysUser.getProId()+""));
            criteria.add(Restrictions.eq("areaid", enterpriseProject.getId()+""));
            criteria.add(Restrictions.like("maintenanceDate",aDate, MatchMode.ANYWHERE));
            if(StringUtils.isNotEmpty(teamid)) {
                criteria.add(Restrictions.eq("maintenanceTroops", teamid));
            }
            List<Mainten> listd = maintenService.findByConditions(criteria);

            if(listd.size()>0){
                times=listd.size();
            }else{
                times=0;
            }
            sl += "," + times;
        }
        msgInfo.setData(xiabiao);
        sl = sl.replaceFirst(",", "");
        sl = "[" + sl + "]";
        msgInfo.setDatas(sl);
        return msgInfo;
    }

    /*
   查询队伍名称管理端
   */
    @ResponseBody
    @RequestMapping(value = "getTeam")
    public List<ConstructionTeam> getTeam() {
        DetachedCriteria criteria = DetachedCriteria.forClass(ConstructionTeam.class);
        SysUser sysUser = (SysUser) SecurityUtils.getSubject().getSession().getAttribute("om_user");
        EnterpriseProject enterpriseProject = (EnterpriseProject) SecurityUtils.getSubject().getSession().getAttribute("area");
        criteria.add(Restrictions.eq("t_project_id", sysUser.getProId()));
        criteria.add(Restrictions.eq("t_area_id", enterpriseProject.getId()));
        if(sysUser.getTeam_id()!=null){
            criteria.add(Restrictions.eq("id", sysUser.getTeam_id()));
        }
        List<ConstructionTeam> list = constructionTeamService.findByConditions(criteria);
        return list;
    }

    /**
     * 企业统计4种养护
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping(value="qytop")
    public MsgInfo statistics(){
        MsgInfo msgInfo = new MsgInfo();
        SysUser sysUser = (SysUser) SecurityUtils.getSubject().getSession().getAttribute("om_user");
        EnterpriseProject enterpriseProject = (EnterpriseProject) SecurityUtils.getSubject().getSession().getAttribute("area");

        JsonObject test=new JsonObject();
        //绿地
        DetachedCriteria criterial = DetachedCriteria.forClass(Mainten.class);
        criterial.add(Restrictions.eq("departid", sysUser.getProId()+""));
        criterial.add(Restrictions.eq("type", 1));
        List<Mainten> listl = maintenService.findByConditions(criterial);
        if(listl.size()>0){
            test.addProperty("lv", listl.size());
        }else{
            test.addProperty("lv", 0);
        }

        //卫生
        DetachedCriteria criteriav = DetachedCriteria.forClass(Mainten.class);
        criteriav.add(Restrictions.eq("departid", sysUser.getProId()+""));
        criteriav.add(Restrictions.eq("type", 2));


        List<Mainten> listv = maintenService.findByConditions(criteriav);
        if(listv.size()>0){
            test.addProperty("ws", listv.size());
        }else{
            test.addProperty("ws", 0);
        }

        //设施
        DetachedCriteria criterias = DetachedCriteria.forClass(Mainten.class);
        criterias.add(Restrictions.eq("departid", sysUser.getProId()+""));
        criterias.add(Restrictions.eq("type", 3));


        List<Mainten> lists = maintenService.findByConditions(criterias);
        if(lists.size()>0){
            test.addProperty("ss", lists.size());
        }else{
            test.addProperty("ss", 0);
        }
        //植保
        DetachedCriteria criteriaz = DetachedCriteria.forClass(Mainten.class);
        criteriaz.add(Restrictions.eq("departid", sysUser.getProId()+""));
        criteriaz.add(Restrictions.eq("type", 4));


        List<Mainten> listz = maintenService.findByConditions(criteriaz);
        if(listz.size()>0){
            test.addProperty("zb", listz.size());
        }else{
            test.addProperty("zb", 0);
        }



        msgInfo.setData(test.toString());
        return msgInfo;
    }
    /**
     * 企业默认4种绿地内容
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping(value="qylvdi")
    public MsgInfo qylvdi(){
        MsgInfo msgInfo = new MsgInfo();
        SysUser sysUser = (SysUser) SecurityUtils.getSubject().getSession().getAttribute("om_user");
        EnterpriseProject enterpriseProject = (EnterpriseProject) SecurityUtils.getSubject().getSession().getAttribute("area");
        JsonObject test=new JsonObject();


        //绿地
        DetachedCriteria criterial = DetachedCriteria.forClass(Mainten.class);
        criterial.add(Restrictions.eq("departid", sysUser.getProId()+""));
        criterial.add(Restrictions.eq("type", 1));

        List<Mainten> list = maintenService.findByConditions(criterial);
        int zg=0; int qd=0; int sf=0;  int fz=0;
        if(list.size()>0){
            for(int i=0;i<list.size();i++){
                if(list.get(i).getMaintenType().getName().equals("中耕除草")){
                    zg++;
                }
                if(list.get(i).getMaintenType().getName().equals("签到打卡")){
                    qd++;
                }
                if(list.get(i).getMaintenType().getName().equals("施肥")){
                    sf++;
                }
                if(list.get(i).getMaintenType().getName().equals("复壮")){
                    fz++;
                }

            }
            test.addProperty("zg", zg);
            test.addProperty("qd", qd);
            test.addProperty("sf", sf);
            test.addProperty("fz", fz);
        }
        msgInfo.setData(test.toString());
        return msgInfo;
    }


    /**
     * 施工角色首页数据
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping(value="sgtop")
    public MsgInfo sgstatistics(){
        MsgInfo msgInfo = new MsgInfo();
        SysUser sysUser = (SysUser) SecurityUtils.getSubject().getSession().getAttribute("om_user");
        EnterpriseProject enterpriseProject = (EnterpriseProject) SecurityUtils.getSubject().getSession().getAttribute("area");
        JsonObject test=new JsonObject();

        //绿地
        DetachedCriteria criterial = DetachedCriteria.forClass(Mainten.class);
        criterial.add(Restrictions.eq("maintenanceTroops", sysUser.getTeam_id()+""));
        criterial.add(Restrictions.eq("type", 1));
        criterial.add(Restrictions.eq("enterpriseid", sysUser.getEnterprise().getId()));
        List<Mainten> listl = maintenService.findByConditions(criterial);
        if(listl.size()>0){
            test.addProperty("lv", listl.size());
        }else{
            test.addProperty("lv", 0);
        }
        //卫生
        DetachedCriteria criteriav = DetachedCriteria.forClass(Mainten.class);
        criteriav.add(Restrictions.eq("maintenanceTroops", sysUser.getTeam_id()+""));
        criteriav.add(Restrictions.eq("type", 2));
        criteriav.add(Restrictions.eq("enterpriseid", sysUser.getEnterprise().getId()));
        List<Mainten> listv = maintenService.findByConditions(criteriav);
        if(listv.size()>0){
            test.addProperty("ws", listv.size());
        }else{
            test.addProperty("ws", 0);
        }
        //设施
        DetachedCriteria criterias = DetachedCriteria.forClass(Mainten.class);
        criterias.add(Restrictions.eq("maintenanceTroops", sysUser.getTeam_id()+""));
        criterias.add(Restrictions.eq("type", 3));
        criterias.add(Restrictions.eq("enterpriseid", sysUser.getEnterprise().getId()));
        List<Mainten> lists = maintenService.findByConditions(criterias);
        if(lists.size()>0){
            test.addProperty("ss", lists.size());
        }else{
            test.addProperty("ss", 0);
        }
        //植保
        DetachedCriteria criteriaz = DetachedCriteria.forClass(Mainten.class);
        criteriaz.add(Restrictions.eq("maintenanceTroops", sysUser.getTeam_id()+""));
        criteriaz.add(Restrictions.eq("type", 4));
        criteriaz.add(Restrictions.eq("enterpriseid", sysUser.getEnterprise().getId()));
        List<Mainten> listz = maintenService.findByConditions(criteriaz);
        if(listz.size()>0){
            test.addProperty("zb", listz.size());
        }else{
            test.addProperty("zb", 0);
        }
        msgInfo.setData(test.toString());
        return msgInfo;
    }


    /**
     * 管理端 4种分类 饼图
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping(value="gltop")
    public MsgInfo gltop(){
        MsgInfo msgInfo = new MsgInfo();
        DetachedCriteria criteria = DetachedCriteria.forClass(Mainten.class);
        SysUser sysUser = (SysUser) SecurityUtils.getSubject().getSession().getAttribute("om_user");
        EnterpriseProject enterpriseProject = (EnterpriseProject) SecurityUtils.getSubject().getSession().getAttribute("area");
        criteria.add(Restrictions.eq("departid", sysUser.getProId()+""));
        criteria.add(Restrictions.eq("areaid", enterpriseProject.getId()+""));
        JsonObject test=new JsonObject();
        DetachedCriteria criteriam = DetachedCriteria.forClass(Mainten.class);
        criteriam.add(Restrictions.eq("departid", sysUser.getProId()+""));
        criteriam.add(Restrictions.eq("areaid", enterpriseProject.getId()+""));


        List<Mainten> listm = maintenService.findByConditions(criteriam);
        if(listm.size()>0){
            test.addProperty("month", listm.size());
        }else{
            test.addProperty("month", 0);
        }

        //当月绿地
        DetachedCriteria criterial = DetachedCriteria.forClass(Mainten.class);
        criterial.add(Restrictions.eq("departid", sysUser.getProId()+""));
        criterial.add(Restrictions.eq("areaid", enterpriseProject.getId()+""));
        criterial.add(Restrictions.eq("type", 1));

        List<Mainten> listl = maintenService.findByConditions(criterial);
        if(listl.size()>0){
            test.addProperty("lv", listl.size());
        }else{
            test.addProperty("lv", 0);
        }

        //当月卫生
        DetachedCriteria criteriav = DetachedCriteria.forClass(Mainten.class);
        criteriav.add(Restrictions.eq("departid", sysUser.getProId()+""));
        criteriav.add(Restrictions.eq("areaid", enterpriseProject.getId()+""));
        criteriav.add(Restrictions.eq("type", 2));

        List<Mainten> listv = maintenService.findByConditions(criteriav);
        if(listv.size()>0){
            test.addProperty("ws", listv.size());
        }else{
            test.addProperty("ws", 0);
        }

        //当月设施
        DetachedCriteria criterias = DetachedCriteria.forClass(Mainten.class);
        criterias.add(Restrictions.eq("departid", sysUser.getProId()+""));
        criterias.add(Restrictions.eq("areaid", enterpriseProject.getId()+""));
        criterias.add(Restrictions.eq("type", 3));

        List<Mainten> lists = maintenService.findByConditions(criterias);
        if(lists.size()>0){
            test.addProperty("ss", lists.size());
        }else{
            test.addProperty("ss", 0);
        }
        //当月植保
        DetachedCriteria criteriaz = DetachedCriteria.forClass(Mainten.class);
        criteriaz.add(Restrictions.eq("departid", sysUser.getProId()+""));
        criteriaz.add(Restrictions.eq("areaid", enterpriseProject.getId()+""));
        criteriaz.add(Restrictions.eq("type", 4));

        List<Mainten> listz = maintenService.findByConditions(criteriaz);
        if(listz.size()>0){
            test.addProperty("zb", listz.size());
        }else{
            test.addProperty("zb", 0);
        }



        msgInfo.setData(test.toString());
        return msgInfo;
    }
}
